Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extra-native-rdr3): GET_MINIMAP_TYPE #3150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KadDarem
Copy link

Goal of this PR

Get the minimap type in RDR3

...

How is this PR achieving the goal

Return the value 0,1,2 or 3 depending on whether the map is off, standard, expended, or simple.
...

This PR applies to the following area(s)

RedM natives

...

Successfully tested on

Get the minimap type after edit it with SetMinimapType(): ✅
Get the minimap type after edit it in the pause menu: ✅

Game builds: 1491

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

Fixed the missing native to get the minimap type set by SetMinimapType()

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Feb 13, 2025
@KadDarem KadDarem force-pushed the extra-native-rdr3/get_minimap_type branch from 58a7a2a to d8dacab Compare February 16, 2025 22:29
@outsider31000
Copy link
Contributor

just a note for the Cfx team if it helps, I was able to test this and works as intended
although I'm not sure if scanning patterns inside native handlers is a good idea...

@KadDarem can you please resolve the comments I made? it's now outdated so it doesnt confuse the team, just to make it easier for them to merge this.

@KadDarem
Copy link
Author

Hi @outsider31000

I tried to find another pattern to get this value to avoid the launcher crash when I use it outside the native handlers.

I found the pointer valueon CE but his pattern doesn't work. So help is welcoming.

It's the first time I work with pattern scanning, not easy

@outsider31000
Copy link
Contributor

The crash might be occurring because the pattern you're using to locate the address is probably dynamic
and that is also why it works inside the native handler, but this is just my guess...

@KadDarem KadDarem changed the title feat(extra-native-rdr3): GET_MINIMAP_TYPE feat(extra-native-rdr3): GET_MINIMAP_TYPE Feb 19, 2025
@KadDarem
Copy link
Author

Do you have tips to find a better pattern ?
I have the static pointer inside my Cheat engine. I think my method to convert it into a pattern is wrong.

@outsider31000
Copy link
Contributor

I have tried to find it for a couple hours and @Ktos93 also helped , but we weren't able to find one

@KadDarem
Copy link
Author

I can give you the CE pointer I found if it can help you.
This pointer is valid for the game built from the source code AND for the game from the launcher AND for another guy. Now, we have to found how to read it and it's done.

@DaniGP17
Copy link
Contributor

I can give you the CE pointer I found if it can help you.

Can you share here so other people can try to help?

@KadDarem
Copy link
Author

<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="46">
  <CheatEntries>
    <CheatEntry>
      <ID>2</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>88</Offset>
        <Offset>0</Offset>
        <Offset>18</Offset>
        <Offset>18</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>3</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>88</Offset>
        <Offset>0</Offset>
        <Offset>18</Offset>
        <Offset>90</Offset>
        <Offset>0</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>4</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03ED0EC0</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>68</Offset>
        <Offset>10</Offset>
        <Offset>28</Offset>
        <Offset>18</Offset>
        <Offset>8</Offset>
        <Offset>1E8</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>5</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03ED0EC0</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>68</Offset>
        <Offset>10</Offset>
        <Offset>28</Offset>
        <Offset>18</Offset>
        <Offset>28</Offset>
        <Offset>158</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>6</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03ED0EC0</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>68</Offset>
        <Offset>10</Offset>
        <Offset>28</Offset>
        <Offset>18</Offset>
        <Offset>48</Offset>
        <Offset>150</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>7</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03ED0EC0</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>68</Offset>
        <Offset>10</Offset>
        <Offset>28</Offset>
        <Offset>98</Offset>
        <Offset>8</Offset>
        <Offset>158</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>8</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03ED0EC0</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>68</Offset>
        <Offset>10</Offset>
        <Offset>28</Offset>
        <Offset>98</Offset>
        <Offset>28</Offset>
        <Offset>150</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>9</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03ED0EC0</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>68</Offset>
        <Offset>10</Offset>
        <Offset>28</Offset>
        <Offset>98</Offset>
        <Offset>48</Offset>
        <Offset>128</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>20</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>18</Offset>
        <Offset>18</Offset>
        <Offset>18</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>21</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EB98F8</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>22</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EB98F8</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>78</Offset>
        <Offset>168</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>23</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EB98F8</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
        <Offset>78</Offset>
        <Offset>168</Offset>
        <Offset>10</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>25</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EB98F8</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>78</Offset>
        <Offset>168</Offset>
        <Offset>10</Offset>
        <Offset>10</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>26</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EB98F8</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>78</Offset>
        <Offset>168</Offset>
        <Offset>78</Offset>
        <Offset>168</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>27</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>90</Offset>
        <Offset>0</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>28</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>18</Offset>
        <Offset>18</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>29</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>18</Offset>
        <Offset>80</Offset>
        <Offset>0</Offset>
        <Offset>0</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>30</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>10</Offset>
        <Offset>18</Offset>
        <Offset>90</Offset>
        <Offset>0</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>31</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>78</Offset>
        <Offset>0</Offset>
        <Offset>0</Offset>
        <Offset>18</Offset>
        <Offset>18</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>32</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>18</Offset>
      </Offsets>
    </CheatEntry>
    <CheatEntry>
      <ID>33</ID>
      <Description>"minimap scan"</Description>
      <LastState Value="3" RealAddress="C350EF90"/>
      <VariableType>Byte</VariableType>
      <Address>"CitiLaunch.exe"+03EF1058</Address>
      <Offsets>
        <Offset>A0</Offset>
        <Offset>0</Offset>
        <Offset>80</Offset>
        <Offset>0</Offset>
        <Offset>0</Offset>
      </Offsets>
    </CheatEntry>
  </CheatEntries>
  <CheatCodes>
    <CodeEntry>
      <Description>minimap :mov eax,[rcx+net-tcp-server.$S1]</Description>
      <AddressString>CitiLaunch.exe+13AE9FC</AddressString>
      <Before>
        <Byte>48</Byte>
        <Byte>8B</Byte>
        <Byte>C1</Byte>
        <Byte>C3</Byte>
        <Byte>CC</Byte>
      </Before>
      <Actual>
        <Byte>8B</Byte>
        <Byte>81</Byte>
        <Byte>A0</Byte>
        <Byte>00</Byte>
        <Byte>00</Byte>
        <Byte>00</Byte>
      </Actual>
      <After>
        <Byte>C3</Byte>
        <Byte>90</Byte>
        <Byte>48</Byte>
        <Byte>83</Byte>
        <Byte>EC</Byte>
      </After>
    </CodeEntry>
  </CheatCodes>
  <UserdefinedSymbols/>
  <Comments>Info about this table:
</Comments>
</CheatTable>

@KadDarem
Copy link
Author

All of these pointers trigger the correct value of the minimap type.

@DaniGP17
Copy link
Contributor

All of these pointers trigger the correct value of the minimap type.

Nice, I'll try to help with that.

@ekaliclua
Copy link

ekaliclua commented Feb 20, 2025

I found a pattern like that, now we have to find the correct way to use it

48 8B C1 C3 CC 8B 81 A0 ?? ?? ?? C3 90 48 83 EC 28

this instruction is called every frame.

@KadDarem
Copy link
Author

KadDarem commented Feb 20, 2025

I found a lot of interesting patterns from my CE pointers, but all crash my launcher if I put them outside the function with the error
"m_matches.size() == expected"

@DaniGP17
Copy link
Contributor

Hi, I find a function that return the minimap type, the function only receives the instance of the class that we already have declared above in a variable called g_uiMinimap.

static hook::cdecl_stub<uint32_t(void*)> g_uiMinimap_GetType([]()
{
	return hook::get_call(hook::get_pattern("E8 ? ? ? ? 83 F8 ? 74 ? 48 8D 15"));
});

fx::ScriptEngine::RegisterNativeHandler("GET_MINIMAP_TYPE", [](fx::ScriptContext& context)
{
        uint32_t minimapType = g_uiMinimap_GetType(g_uiMinimap);
        
        context.SetResult<int>(minimapType);
});

@KadDarem
Copy link
Author

Nice ! I will test that to check if it works in my side too.

@KadDarem
Copy link
Author

It works perfectly, thanks @DaniGP17 .

Can you confirm this refactor resolves your request @outsider31000 ?

@DaniGP17
Copy link
Contributor

It works perfectly, thanks @DaniGP17 .

Glad to hear that 😄

@outsider31000
Copy link
Contributor

outsider31000 commented Feb 23, 2025

it's a static one
image

I will make spome tests
about the implementation thats up to Cfx wait for their review.

you should squash the commits though @KadDarem

@outsider31000
Copy link
Contributor

outsider31000 commented Feb 23, 2025

I have made some tests and i have to clarify, that this native will only detect the type it has been set either by using the native SetMinimapType or through settings, it will not detect the current type of the minimap, just so people are aware.

for example:
1- if you press ESC the minimap hides as in OFF type 0 but still returns last type set (which you could use IS_RADAR_HIDDEN)
2- if you press and hold TAB it expands as in type 2 expanded but still returns last type set (no way to detect this for now)

which makes sense. thats how it should work.

for a detection of current type we would need another native perhaps like GET_CURRENT_MINIMAP_TYPE so it detects the current state.

@KadDarem
Copy link
Author

  1. I agree with you; this native is perfect for detecting which setting is used for the minimap. I'm looking for this native because IsRadarHidden() returns true if the minimap type is set to 0. It was impossible to detect if the minimap was hidden by the DISPLAY_RADAR native or by the SET_MINIMAP_TYPE native.

It's now perfectly possible with this new native.

  1. The native name seems to be right for me. The result matches perfectly with SetMinimapType native or with the settings or with the "Radar" prompts. It's not affected by the game context (tab pressing or pause menu). It's perfect to save the minimap type and be able to apply it again later.

  2. If someone want try to find the GET_CURRENT_MINIMAP_TYPE native, feel free to do it in a new PR since this research for GET_MINIMAP_TYPE is done.

PS : I also tested with the "Radar" prompts and the GET_MINIMAP_TYPE returns the correct result too.

@outsider31000
Copy link
Contributor

yeah this works as intended, just dont forget to squash the commits @KadDarem so it doesn't delay any revivews

@KadDarem KadDarem force-pushed the extra-native-rdr3/get_minimap_type branch from 5b656b5 to d8dacab Compare February 24, 2025 08:48
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed invalid Requires changes before it's considered valid and can be (re)triaged triage Needs a preliminary assessment to determine the urgency and required action labels Feb 24, 2025
@KadDarem KadDarem force-pushed the extra-native-rdr3/get_minimap_type branch from cb42f1c to 333208a Compare February 24, 2025 08:56
@KadDarem KadDarem force-pushed the extra-native-rdr3/get_minimap_type branch from 333208a to 9f06f31 Compare February 24, 2025 09:00
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Feb 24, 2025
@KadDarem
Copy link
Author

Commits squashed.

Thanks for your help everyone ;)

@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants